package com.baijiaoxi.utils.excel;

import lombok.Data;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.ss.usermodel.BorderStyle;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.VerticalAlignment;

@Data
public class HSSFCellStyleFactory {
    private HSSFCellStyle cellStyle;

    public HSSFCellStyleFactory() {
    }

    public HSSFCellStyleFactory(HSSFCellStyle cellStyle) {
        this.cellStyle = cellStyle;
    }

    public static HSSFCellStyleFactory build(HSSFCellStyle cellStyle) {
        HSSFCellStyleFactory factory = new HSSFCellStyleFactory(cellStyle);
        return factory;
    }

    public HSSFCellStyleFactory setAlignment(short alignment) {
        cellStyle.setAlignment(HorizontalAlignment.forInt(alignment));
        return this;
    }

    public HSSFCellStyleFactory setVerticalAlignment(short verticalAlignment) {

        cellStyle.setVerticalAlignment(VerticalAlignment.forInt(verticalAlignment));
        return this;
    }

    public HSSFCellStyleFactory setBorderBottom(short borderBottom) {

        cellStyle.setBorderBottom(BorderStyle.valueOf(borderBottom));
        return this;
    }

    public HSSFCellStyleFactory setBorderTop(short borderTop) {
        cellStyle.setBorderTop(BorderStyle.valueOf(borderTop));
        return this;
    }

    public HSSFCellStyleFactory setBorderLeft(short borderLeft) {
        cellStyle.setBorderLeft(BorderStyle.valueOf(borderLeft));
        return this;
    }

    public HSSFCellStyleFactory setBorderRight(short borderRight) {
        cellStyle.setBorderRight(BorderStyle.valueOf(borderRight));
        return this;
    }

    public HSSFCellStyleFactory setFont(HSSFFont font) {
        cellStyle.setFont(font);
        return this;
    }

    public HSSFCellStyleFactory setShrinkToFit(boolean shrinkToFit) {
        cellStyle.setShrinkToFit(shrinkToFit);
        return this;
    }

    public HSSFCellStyleFactory setWrapped(boolean wrapped) {
        cellStyle.setWrapText(wrapped);
        return this;
    }
}
